package com.a2j.web.car.controller;

import com.a2j.beans.base.BaseBean;
import com.a2j.beans.base.BasePageBean;
import com.a2j.beans.base.code.ResponseCode;
import com.a2j.beans.car.type.CarTypeBySeriesVO;
import com.a2j.beans.car.type.CarTypePageBO;
import com.a2j.beans.car.type.CarTypeVO;
import com.a2j.web.car.service.CarTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Author: bzb
 * Data: 2022/1/19 15:38
 * Desc: 车型controller
 */
@RestController
@RequestMapping("/carType")
@Api(tags = "车型")
public class CarTypeController {

    @Resource
    CarTypeService service;

    /**
     * 新增车型
     * @param record 车型信息
     */
    @PostMapping("/addCarType")
    @ApiOperation(value = "新增车型")
    @ApiImplicitParams({})
    public BaseBean<String> addCarType(@RequestBody CarTypeVO record) {
        service.addCarType(record);
        return BaseBean.success(ResponseCode.SUCCESS);
    }

    /**
     * 删除车型
     * @param id 车型id
     */
    @DeleteMapping("/delCarType/{id}")
    @ApiOperation(value = "删除车型")
    @ApiImplicitParam(name = "id", value = "车型id", required = true, dataType = "int", paramType = "path", defaultValue = "100")
    public BaseBean<String> delCarType(@PathVariable Integer id) {
        service.delCarType(id);
        return BaseBean.success(ResponseCode.SUCCESS);
    }

    /**
     * 车型开关
     * @param id 车型id
     * @param enable 开关
     */
    @PutMapping("/enable")
    @ApiOperation(value = "车型开关")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "车型id", required = true, dataType = "int", defaultValue = "1"),
            @ApiImplicitParam(name = "enable", value = "开关, 0:关  1:开", dataType = "int", defaultValue = "0")
    })
    public BaseBean<String> enable(@RequestParam Integer id, @RequestParam Integer enable) {
        service.enable(id, enable);
        return BaseBean.success(ResponseCode.SUCCESS);
    }

    /**
     * 更新车型信息
     * @param record 车型信息
     */
    @PutMapping("/updateCarTypeInfo")
    @ApiOperation(value = "更新车型信息")
    @ApiImplicitParams({})
    public BaseBean<String> updateCarTypeInfo(@RequestBody CarTypeVO record) {
        service.updateCarTypeInfo(record);
        return BaseBean.success(ResponseCode.SUCCESS);
    }

    /**
     * 查询车型详情
     * @param id 车型id
     * @return 车型信息详情
     */
    @GetMapping("/getCarTypeDetail/{id}")
    @ApiOperation(value = "查询车型详情")
    @ApiImplicitParam(name = "id", value = "车型id", required = true, dataType = "int", paramType = "path")
    public BaseBean<CarTypeVO> getCarTypeDetail(@PathVariable Integer id) {
        return service.getCarTypeDetail(id);
    }

    /**
     * 根据入参条件,查询车型列表(分页)
     * @param record 车型分页及其他条件
     * @return 车型列表(完整数据)
     */
    @GetMapping("/getCarTypes")
    @ApiOperation(value = "查询车型列表", notes = "根据入参条件,查询车型列表(分页)")
    @ApiImplicitParams({})
    public BaseBean<BasePageBean<CarTypeVO>> getCarTypes(@RequestBody CarTypePageBO record) {
        return service.getCarTypes(record);
    }

    /**
     * 根据车系id,查询该分类下所有车型(分页)
     * @param record 车型分页及其他条件
     * @return 车型列表(简易数据)
     */
    @GetMapping("/getCarTypesBySeriesId")
    @ApiOperation(value = "查询车型列表, 根据车系id", notes = "根据车系id,查询该分类下所有车型(分页)")
    @ApiImplicitParams({})
    public BaseBean<BasePageBean<CarTypeBySeriesVO>> getCarTypesBySeriesId(@RequestBody CarTypePageBO record) {
        return service.getCarTypesBySeriesId(record);
    }


    //--------------------------四个额外列表-------------------------------------------

    /**
     * 查询生产年份列表
     */
    @GetMapping("/getYearTypeList")
    @ApiOperation(value = "查询生产年份列表")
    public BaseBean<List<String>> getYearTypeList() {
        return service.getYearTypeList();
    }

    /**
     * 查询排放标准列表
     */
    @GetMapping("/getEffluentStandardList")
    @ApiOperation(value = "查询排放标准列表")
    public BaseBean<List<String>> getEffluentStandardList() {
        return service.getEffluentStandardList();
    }

    /**
     * 查询销售状态列表
     */
    @GetMapping("/getSaleStateList")
    @ApiOperation(value = "查询销售状态列表")
    public BaseBean<List<String>> getSaleStateList() {
        return service.getSaleStateList();
    }

    /**
     * 查询规格类型列表
     */
    @GetMapping("/getSizeTypeList")
    @ApiOperation(value = "查询规格类型列表")
    public BaseBean<List<String>> getSizeTypeList() {
        return service.getSizeTypeList();
    }

}
